<?php
/**
 * Created by PhpStorm.
 * User: 12133
 * Date: 2024/4/30
 * Time: 14:08
 */

namespace app\model;


class Standard extends Base
{
    protected $json = [
       'variable','other_standard','other_algorithm','other_variable'
    ];
    protected $append = [
        'other_array'
    ];
    public static function getStandardName($id){
        $array = [1 => '锻打毛胚',2 => '卷板毛胚',3 => '割坂毛胚'];
        return $array[$id];
    }
    public function getOtherArrayAttr($value,$data){
        $array = [];
        if (!empty($data['other_standard'])) {
            foreach ($data['other_standard'] AS $key => $value) {
                $array[$key] = $value;
                if (!empty($data['other_variable'])) {
                    foreach ($data['other_variable'] AS $index => $item) {
                        if (empty($item['id'])) continue;
                        if ($value['id'] == $item['id']) {
                            $array[$key]['vara'][] = $item;
                        }
                    }
                }
                if (!empty($data['other_algorithm'])) {
                    foreach ($data['other_algorithm'] AS $index => $item) {
                        if (empty($item['id'])) continue;
                        if ($value['id'] == $item['id']) {
                            $array[$key]['result'][] = $item;
                        }
                    }
                }
            }
        }
        return $array;
    }
}